package server

import scala.actors._
import scala.actors.remote._
import scala.actors.remote.RemoteActor._
import java.net._

class ServerConnector extends Actor {
	
	val sched : Scheduler = new Scheduler(new ClientPool(), new AssignmentPool()); sched.start()
	
	def act()
	{
		RemoteActor.classLoader = getClass().getClassLoader()
		
		// Set to listen on port 1337 for messages
		alive(1337)
		
		// Register the actor as 'serverConnetor'
		register( Symbol("serverConnector") , this )
		
		
		loop
		{
			react
			{
				case statusMessage : messages.StatusMessage =>			
					sched forward statusMessage
					
				case requestAssignment : messages.RequestAssignment =>
					sched forward requestAssignment
					
				case message : messages.Destination =>
					sched forward message
					
			}
		}
	}

}